/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SMeterInputConverter.java
 * Created：		2016年8月30日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.common;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.OperateInfo;
import com.thor.commons.util.StringUtil;
import com.thor.palmmall.spi.common.SOperateInfo;

/**
 * @author wolv
 *
 */
public class OperateInfoConverter implements Converter<SOperateInfo, OperateInfo> {

	public static OperateInfoConverter getInstance() {
		if (instance == null)
			instance = new OperateInfoConverter();
		return instance;
	}

	private static OperateInfoConverter instance;

	private OperateInfoConverter() {
	}

	@Override
	public OperateInfo convert(SOperateInfo source) {
		if (source == null)
			return null;

		OperateInfo target = new OperateInfo();
		target.setOperator(OperatorConverter.getInstance().convert(source.getOperator()));
		try {
			target.setTime(StringUtil.toDate(source.getTime(), "yyyy.MM.dd HH:mm:ss"));
		} catch (Exception e) {
		}

		return target;
	}
}
